using LiJ.Common.Extention;
using System.Collections.Generic;

namespace LiJ.Pay.WeiXin.Pay.Mos
{
	public class WxPayRefundResp : WxPayBaseResp
	{
		/// <summary>   
		///    设备号 可空 String(32) 终端设备号
		/// </summary>  
		public string device_info
		{
			get;
			set;
		}

		/// <summary>   
		///    微信订单号 必填 String(28) 微信订单号
		/// </summary>  
		public string transaction_id
		{
			get;
			set;
		}

		/// <summary>   
		///    商户订单号 必填 String(32) 商户系统内部的订单号
		/// </summary>  
		public string out_trade_no
		{
			get;
			set;
		}

		/// <summary>   
		///    商户退款单号 必填 String(32) 商户退款单号
		/// </summary>  
		public string out_refund_no
		{
			get;
			set;
		}

		/// <summary>   
		///    微信退款单号 必填 String(28) 微信退款单号
		/// </summary>  
		public string refund_id
		{
			get;
			set;
		}

		/// <summary>   
		///    退款渠道 可空 String(16) ORIGINAL—原路退款 BALANCE—退回到余额
		/// </summary>  
		public string refund_channel
		{
			get;
			set;
		}

		/// <summary>   
		///    退款金额 必填 Int 退款总金额,单位为分,可以做部分退款
		/// </summary>  
		public int refund_fee
		{
			get;
			set;
		}

		public int settlement_refund_fee
		{
			get;
			set;
		}

		/// <summary>   
		///    标价金额 必填 Int 订单总金额，单位为分，只能为整数，详见支付金额
		/// </summary>  
		public int total_fee
		{
			get;
			set;
		}

		public int settlement_total_fee
		{
			get;
			set;
		}

		/// <summary>   
		///    标价币种 可空 String(8) 订单金额货币类型，符合ISO 4217标准的三位字母代码，默认人民币：CNY，其他值列表详见货币类型
		/// </summary>  
		public string fee_type
		{
			get;
			set;
		}

		/// <summary>   
		///    现金支付金额 必填 Int 现金支付金额，单位为分，只能为整数，详见支付金额
		/// </summary>  
		public int cash_fee
		{
			get;
			set;
		}

		/// <summary>   
		///    现金支付币种 可空 String(16) 货币类型，符合ISO 4217标准的三位字母代码，默认人民币：CNY，其他值列表详见货币类型
		/// </summary>  
		public string cash_fee_type
		{
			get;
			set;
		}

		/// <summary>   
		///    现金退款金额 可空 Int 现金退款金额，单位为分，只能为整数，详见支付金额
		/// </summary>  
		public string cash_refund_fee
		{
			get;
			set;
		}

		/// <summary>   
		///    代金券退款总金额 可空 Int 代金券退款金额小于退款金额，退款金额-代金券或立减优惠退款金额为现金，说明详见代金券或立减优惠
		/// </summary>  
		public string coupon_refund_fee
		{
			get;
			set;
		}

		/// <summary>   
		///    退款代金券使用数量 可空 Int 退款代金券使用数量
		/// </summary>  
		public int coupon_refund_count
		{
			get;
			set;
		}

		/// <summary>
		/// 退款代金券信息
		/// </summary>
		public List<WxPayOrderCouponMo> refund_coupons
		{
			get;
			set;
		}

		/// <summary>
		/// 格式化自身属性部分
		/// </summary>
		protected override void FormatPropertiesFromMsg()
		{
			this.device_info = base["device_info"];
			this.transaction_id = base["transaction_id"];
			this.out_trade_no = base["out_trade_no"];
			this.out_refund_no = base["out_refund_no"];
			this.refund_id = base["refund_id"];
			this.refund_channel = base["refund_channel"];
			this.refund_fee = base["refund_fee"].ToInt32(0);
			this.settlement_refund_fee = base["settlement_refund_fee"].ToInt32(0);
			this.total_fee = base["total_fee"].ToInt32(0);
			this.settlement_total_fee = base["settlement_total_fee"].ToInt32(0);
			this.fee_type = base["fee_type"];
			this.cash_fee = base["cash_fee"].ToInt32(0);
			this.cash_fee_type = base["cash_fee_type"];
			this.cash_refund_fee = base["cash_refund_fee"];
			this.coupon_refund_fee = base["coupon_refund_fee"];
			this.coupon_refund_count = base["coupon_refund_count"].ToInt32(0);
			if (this.coupon_refund_count > 0)
			{
				this.refund_coupons = new List<WxPayOrderCouponMo>(this.coupon_refund_count);
				for (int i = 0; i < this.coupon_refund_count; i++)
				{
					WxPayOrderCouponMo obj = new WxPayOrderCouponMo
					{
						coupon_fee = base["coupon_refund_fee_" + i].ToInt32(0),
						coupon_id = base["coupon_refund_id_" + i],
						coupon_type = base["coupon_type_" + i]
					};
				}
			}
		}
	}
}
